package com.example.towSpringBoot.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @description: 封装结果
 * @author: xinTong
 * @create: 2024-01-23 15:37
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
    private int code;// 状态码
    private String msg;// 操作提示信息
    private String status;// 操作提示信息
    private Object data;// 数据
    public static final String SUCCESS = "success";
    public static final String FAIL = "fail";

    public static Result fail(){
        return new Result(400,"",FAIL, null);
    }

    public static Result fail(String msg){
        return new Result(400,msg,FAIL, null);
    }

    public static Result success(){
        return new Result(200,"",SUCCESS, null);
    }

    public static Result success(Object data){
        return new Result(200,"",SUCCESS, data);
    }

    public static Result success(String msg, Object data){
        return new Result(200,msg,SUCCESS,data);
    }
}
